package com.bjesc_b2c.app.appraiset.widget.popupwindow;

import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bjesc_b2c.app.appraiset.R;
import com.bjesc_b2c.app.appraiset.widget.BasePopupWindow;

/**
 * Created by yidong on 2017/5/27.
 */

public class FileterCondPop extends BasePopupWindow {
    private TextView tv_car_name, tv_car_main, tv_car_vin,tv_car_id;
    public int popupWidth;
    public int popupHeight;
    public FileterCondPop(Context context, View.OnClickListener listener ) {
        super(context, listener);
    }

    @Override
    protected void initViews() {
        view = inflater.inflate(R.layout.layout_pop_filter_condition, null);
        tv_car_name = (TextView) view.findViewById(R.id.tv_car_name);
        tv_car_main = (TextView) view.findViewById(R.id.tv_car_main);
        tv_car_vin = (TextView) view.findViewById(R.id.tv_car_vin);
        tv_car_id = (TextView) view.findViewById(R.id.tv_car_id);
        tv_car_name.setOnClickListener(listener);
        tv_car_main.setOnClickListener(listener);
        tv_car_vin.setOnClickListener(listener);
        tv_car_id.setOnClickListener(listener);
        view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);//这句很重要 不是获取不到宽高
        popupHeight = view.getMeasuredHeight();
        popupWidth = view.getMeasuredWidth();
    }

    @Override
    protected void setView() {
        super.setView();
        this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    @Override
    protected int setRootViewId() {
        return R.id.root;
    }

    public void showAtView(View parent) {
        int[] location = new int[2];
        parent.getLocationOnScreen(location);
        showAtLocation(parent, Gravity.NO_GRAVITY, (location[0] + parent.getWidth() / 2) - popupWidth / 2, location[1] - popupHeight);
    }
}
